package cn.haoxsf.app.common.exception;

import cn.haoxsf.app.common.api.enums.IServiceEnum;
import lombok.Getter;

/**
 * @program: app
 * @description: 异常基类
 * @author: Ele qvbanfm@qq.com
 * @create: 2020-01-06 09:48
 **/
@Getter
public class BaseException extends RuntimeException{
    Integer code ;
    String msg;

    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public BaseException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public BaseException(IServiceEnum serviceEnum) {
        this.code = serviceEnum.getCode();
        this.msg = serviceEnum.getMsg();
    }
    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public BaseException() {
    }

    @Override
    public String getMessage() {
        return msg;
    }
}
